import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = 0;
        for(int i = 0;i < 5;i++){
            int x = scanner.nextInt();
            int[] arr = new int[4];
            for(int j = 0;j < 4;j++){
                arr[j] = x%10;
                x/=10;
            }
            if(arr[0]-arr[2] == 1 && arr[1] ==arr[3]){
                count++;
            }
        }
        System.out.print(count);

    }
}